package training;


public class JavaConstructs {

	int id;
	String name;

	public void setUp(int id, String name) {
		this.id = id;
		this.name = name;

	}

	public static void main(String[] args) {

		// for(initialization; termination condition; incremental condition)

		for (int i = 0; i < 10; i++) {
			System.out.println("For Counter is :" + i);
		}

		int i = 10;
		while (i < 10) {

			System.out.println("While Counter is :" + i);
			i++;

		}

		i = 10;

		do {

			System.out.println("DoWhile Counter is :" + i);
			i++;

		} while (i < 10);

		byte byteValue = (byte) 135;

		System.out.println("byte value :" + byteValue);

		short shortValue = (short) 330000;

		System.out.println("short value : " + shortValue);

		int caseId = 3;

		// switch is always better alternative for multiple if else conditions.

		if (caseId == 0) {

			System.out.println("if  caseId value is 0");
			if (true) {
				System.out.println("if  caseId is 0");
			}

		} else if (caseId == 1) {
			System.out.println("if caseId is 1");

		} else if (caseId == 2) {
			System.out.println("if  caseId is 2");

		} else if (caseId == 3) {
			System.out.println("if caseId is 3");
		} else {
			//
			System.out.println("if  caseId is something else");
		}	
		
		
		System.out.println("************************** Switch demo *******************");
		caseId = 1;
		switch (caseId) {
		case 0:
			System.out.println("caseId is 0");
			//break;
		case 1:
			System.out.println("caseId is 1");
			//break;
		case 2:
			System.out.println("caseId is 2");
			break;
		case 3:
			System.out.println("caseId is 3");
			break;
		default:
			System.out.println("something else");

		}
		System.out.println("************************** Switch demo *******************");
		for (i = 0; i > -1; i++) {
			System.out.println("Hello :" + i);
			if (i == 10) {
				break;
			}
		}
	}

	/**
	 * 1. what will happen if we write for(;;){System.out.println("hello")} 2.
	 * reason the output for the lines below.
	 * 
	 * byte byteValue = (byte) 277;
	 * 
	 * System.out.println("byte value :" + byteValue);
	 * 
	 * short shortValue = (short) 330000;
	 * 
	 * System.out.println("short value : " + shortValue);
	 * 
	 */

}
